<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>abstractrange.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="closure_goog_dom_abstractrange.js.html">abstractrange.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2007 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Interface definitions for working with ranges
<a name="line17"></a> * in HTML documents.
<a name="line18"></a> *
<a name="line19"></a> * @author robbyw@google.com (Robby Walker)
<a name="line20"></a> */
<a name="line21"></a>
<a name="line22"></a>
<a name="line23"></a>goog.provide(&#39;goog.dom.AbstractRange&#39;);
<a name="line24"></a>goog.provide(&#39;goog.dom.RangeIterator&#39;);
<a name="line25"></a>goog.provide(&#39;goog.dom.RangeType&#39;);
<a name="line26"></a>
<a name="line27"></a>goog.require(&#39;goog.dom&#39;);
<a name="line28"></a>goog.require(&#39;goog.dom.NodeType&#39;);
<a name="line29"></a>goog.require(&#39;goog.dom.SavedCaretRange&#39;);
<a name="line30"></a>goog.require(&#39;goog.dom.TagIterator&#39;);
<a name="line31"></a>goog.require(&#39;goog.userAgent&#39;);
<a name="line32"></a>
<a name="line33"></a>
<a name="line34"></a>/**
<a name="line35"></a> * Types of ranges.
<a name="line36"></a> * @enum {string}
<a name="line37"></a> */
<a name="line38"></a>goog.dom.RangeType = {
<a name="line39"></a>  TEXT: &#39;text&#39;,
<a name="line40"></a>  CONTROL: &#39;control&#39;,
<a name="line41"></a>  MULTI: &#39;mutli&#39;
<a name="line42"></a>};
<a name="line43"></a>
<a name="line44"></a>
<a name="line45"></a>
<a name="line46"></a>/**
<a name="line47"></a> * Creates a new selection with no properties.  Do not use this constructor -
<a name="line48"></a> * use one of the goog.dom.Range.from* methods instead.
<a name="line49"></a> * @constructor
<a name="line50"></a> */
<a name="line51"></a>goog.dom.AbstractRange = function() {
<a name="line52"></a>};
<a name="line53"></a>
<a name="line54"></a>
<a name="line55"></a>/**
<a name="line56"></a> * Gets the browser native selection object from the given window.
<a name="line57"></a> * @param {Window} win The window to get the selection object from.
<a name="line58"></a> * @return {Object} The browser native selection object, or null if it could
<a name="line59"></a> *     not be retrieved.
<a name="line60"></a> */
<a name="line61"></a>goog.dom.AbstractRange.getBrowserSelectionForWindow = function(win) {
<a name="line62"></a>  if (win.getSelection) {
<a name="line63"></a>    // W3C
<a name="line64"></a>    return win.getSelection();
<a name="line65"></a>  } else {
<a name="line66"></a>    // IE
<a name="line67"></a>    var doc = win.document;
<a name="line68"></a>    var sel = doc.selection;
<a name="line69"></a>    if (sel) {
<a name="line70"></a>      // IE has a bug where it sometimes returns a selection from the wrong
<a name="line71"></a>      // document. Catching these cases now helps us avoid problems later.
<a name="line72"></a>      try {
<a name="line73"></a>        var range = sel.createRange();
<a name="line74"></a>        // Only TextRanges have a parentElement method.
<a name="line75"></a>        if (range.parentElement) {
<a name="line76"></a>          if (range.parentElement().document != doc) {
<a name="line77"></a>            return null;
<a name="line78"></a>          }
<a name="line79"></a>        } else if (!range.length || range.item(0).document != doc) {
<a name="line80"></a>          // For ControlRanges, check that the range has items, and that
<a name="line81"></a>          // the first item in the range is in the correct document.
<a name="line82"></a>          return null;
<a name="line83"></a>        }
<a name="line84"></a>      } catch (e) {
<a name="line85"></a>        // If the selection is in the wrong document, and the wrong document is
<a name="line86"></a>        // in a different domain, IE will throw an exception.
<a name="line87"></a>        return null;
<a name="line88"></a>      }
<a name="line89"></a>      // TODO(user|robbyw) Sometimes IE 6 returns a selection instance
<a name="line90"></a>      // when there is no selection.  This object has a &#39;type&#39; property equals
<a name="line91"></a>      // to &#39;None&#39; and a typeDetail property bound to undefined. Ideally this
<a name="line92"></a>      // function should not return this instance.
<a name="line93"></a>      return sel;
<a name="line94"></a>    }
<a name="line95"></a>    return null;
<a name="line96"></a>  }
<a name="line97"></a>};
<a name="line98"></a>
<a name="line99"></a>
<a name="line100"></a>/**
<a name="line101"></a> * Tests if the given Object is a controlRange.
<a name="line102"></a> * @param {Object} range The range object to test.
<a name="line103"></a> * @return {boolean} Whether the given Object is a controlRange.
<a name="line104"></a> */
<a name="line105"></a>goog.dom.AbstractRange.isNativeControlRange = function(range) {
<a name="line106"></a>  // For now, tests for presence of a control range function.
<a name="line107"></a>  return !!range &amp;&amp; !!range.addElement;
<a name="line108"></a>};
<a name="line109"></a>
<a name="line110"></a>
<a name="line111"></a>/**
<a name="line112"></a> * @return {goog.dom.AbstractRange} A clone of this range.
<a name="line113"></a> */
<a name="line114"></a>goog.dom.AbstractRange.prototype.clone = goog.abstractMethod;
<a name="line115"></a>
<a name="line116"></a>
<a name="line117"></a>/**
<a name="line118"></a> * @return {goog.dom.RangeType} The type of range represented by this object.
<a name="line119"></a> */
<a name="line120"></a>goog.dom.AbstractRange.prototype.getType = goog.abstractMethod;
<a name="line121"></a>
<a name="line122"></a>
<a name="line123"></a>/**
<a name="line124"></a> * @return {Range|TextRange} The native browser range object.
<a name="line125"></a> */
<a name="line126"></a>goog.dom.AbstractRange.prototype.getBrowserRangeObject = goog.abstractMethod;
<a name="line127"></a>
<a name="line128"></a>
<a name="line129"></a>/**
<a name="line130"></a> * Sets the native browser range object, overwriting any state this range was
<a name="line131"></a> * storing.
<a name="line132"></a> * @param {Range|TextRange} nativeRange The native browser range object.
<a name="line133"></a> * @return {boolean} Whether the given range was accepted.  If not, the caller
<a name="line134"></a> *     will need to call goog.dom.Range.createFromBrowserRange to create a new
<a name="line135"></a> *     range object.
<a name="line136"></a> */
<a name="line137"></a>goog.dom.AbstractRange.prototype.setBrowserRangeObject = function(nativeRange) {
<a name="line138"></a>  return false;
<a name="line139"></a>};
<a name="line140"></a>
<a name="line141"></a>
<a name="line142"></a>/**
<a name="line143"></a> * @return {number} The number of text ranges in this range.
<a name="line144"></a> */
<a name="line145"></a>goog.dom.AbstractRange.prototype.getTextRangeCount = goog.abstractMethod;
<a name="line146"></a>
<a name="line147"></a>
<a name="line148"></a>/**
<a name="line149"></a> * Get the i-th text range in this range.  The behavior is undefined if
<a name="line150"></a> * i &gt;= getTextRangeCount or i &lt; 0.
<a name="line151"></a> * @param {number} i The range number to retrieve.
<a name="line152"></a> * @return {goog.dom.TextRange} The i-th text range.
<a name="line153"></a> */
<a name="line154"></a>goog.dom.AbstractRange.prototype.getTextRange = goog.abstractMethod;
<a name="line155"></a>
<a name="line156"></a>
<a name="line157"></a>/**
<a name="line158"></a> * Gets an array of all text ranges this range is comprised of.  For non-multi
<a name="line159"></a> * ranges, returns a single element array containing this.
<a name="line160"></a> * @return {Array.&lt;goog.dom.TextRange&gt;} Array of text ranges.
<a name="line161"></a> */
<a name="line162"></a>goog.dom.AbstractRange.prototype.getTextRanges = function() {
<a name="line163"></a>  var output = [];
<a name="line164"></a>  for (var i = 0, len = this.getTextRangeCount(); i &lt; len; i++) {
<a name="line165"></a>    output.push(this.getTextRange(i));
<a name="line166"></a>  }
<a name="line167"></a>  return output;
<a name="line168"></a>};
<a name="line169"></a>
<a name="line170"></a>
<a name="line171"></a>/**
<a name="line172"></a> * @return {Node} The deepest node that contains the entire range.
<a name="line173"></a> */
<a name="line174"></a>goog.dom.AbstractRange.prototype.getContainer = goog.abstractMethod;
<a name="line175"></a>
<a name="line176"></a>
<a name="line177"></a>/**
<a name="line178"></a> * Returns the deepest element in the tree that contains the entire range.
<a name="line179"></a> * @return {Element} The deepest element that contains the entire range.
<a name="line180"></a> */
<a name="line181"></a>goog.dom.AbstractRange.prototype.getContainerElement = function() {
<a name="line182"></a>  var node = this.getContainer();
<a name="line183"></a>  return /** @type {Element} */ (
<a name="line184"></a>      node.nodeType == goog.dom.NodeType.ELEMENT ? node : node.parentNode);
<a name="line185"></a>};
<a name="line186"></a>
<a name="line187"></a>
<a name="line188"></a>/**
<a name="line189"></a> * @return {Node} The element or text node the range starts in.  For text
<a name="line190"></a> *     ranges, the range comprises all text between the start and end position.
<a name="line191"></a> *     For other types of range, start and end give bounds of the range but
<a name="line192"></a> *     do not imply all nodes in those bounds are selected.
<a name="line193"></a> */
<a name="line194"></a>goog.dom.AbstractRange.prototype.getStartNode = goog.abstractMethod;
<a name="line195"></a>
<a name="line196"></a>
<a name="line197"></a>/**
<a name="line198"></a> * @return {number} The offset into the node the range starts in.  For text
<a name="line199"></a> *     nodes, this is an offset into the node value.  For elements, this is
<a name="line200"></a> *     an offset into the childNodes array.
<a name="line201"></a> */
<a name="line202"></a>goog.dom.AbstractRange.prototype.getStartOffset = goog.abstractMethod;
<a name="line203"></a>
<a name="line204"></a>
<a name="line205"></a>/**
<a name="line206"></a> * @return {goog.math.Coordinate} The coordinate of the selection start node
<a name="line207"></a> *     and offset.
<a name="line208"></a> */
<a name="line209"></a>goog.dom.AbstractRange.prototype.getStartPosition = goog.abstractMethod;
<a name="line210"></a>
<a name="line211"></a>
<a name="line212"></a>/**
<a name="line213"></a> * @return {Node} The element or text node the range ends in.
<a name="line214"></a> */
<a name="line215"></a>goog.dom.AbstractRange.prototype.getEndNode = goog.abstractMethod;
<a name="line216"></a>
<a name="line217"></a>
<a name="line218"></a>/**
<a name="line219"></a> * @return {number} The offset into the node the range ends in.  For text
<a name="line220"></a> *     nodes, this is an offset into the node value.  For elements, this is
<a name="line221"></a> *     an offset into the childNodes array.
<a name="line222"></a> */
<a name="line223"></a>goog.dom.AbstractRange.prototype.getEndOffset = goog.abstractMethod;
<a name="line224"></a>
<a name="line225"></a>
<a name="line226"></a>/**
<a name="line227"></a> * @return {goog.math.Coordinate} The coordinate of the selection end
<a name="line228"></a> *     node and offset.
<a name="line229"></a> */
<a name="line230"></a>goog.dom.AbstractRange.prototype.getEndPosition = goog.abstractMethod;
<a name="line231"></a>
<a name="line232"></a>
<a name="line233"></a>/**
<a name="line234"></a> * @return {Node} The element or text node the range is anchored at.
<a name="line235"></a> */
<a name="line236"></a>goog.dom.AbstractRange.prototype.getAnchorNode = function() {
<a name="line237"></a>  return this.isReversed() ? this.getEndNode() : this.getStartNode();
<a name="line238"></a>};
<a name="line239"></a>
<a name="line240"></a>
<a name="line241"></a>/**
<a name="line242"></a> * @return {number} The offset into the node the range is anchored at.  For
<a name="line243"></a> *     text nodes, this is an offset into the node value.  For elements, this
<a name="line244"></a> *     is an offset into the childNodes array.
<a name="line245"></a> */
<a name="line246"></a>goog.dom.AbstractRange.prototype.getAnchorOffset = function() {
<a name="line247"></a>  return this.isReversed() ? this.getEndOffset() : this.getStartOffset();
<a name="line248"></a>};
<a name="line249"></a>
<a name="line250"></a>
<a name="line251"></a>/**
<a name="line252"></a> * @return {Node} The element or text node the range is focused at - i.e. where
<a name="line253"></a> *     the cursor is.
<a name="line254"></a> */
<a name="line255"></a>goog.dom.AbstractRange.prototype.getFocusNode = function() {
<a name="line256"></a>  return this.isReversed() ? this.getStartNode() : this.getEndNode();
<a name="line257"></a>};
<a name="line258"></a>
<a name="line259"></a>
<a name="line260"></a>/**
<a name="line261"></a> * @return {number} The offset into the node the range is focused at - i.e.
<a name="line262"></a> *     where the cursor is.  For text nodes, this is an offset into the node
<a name="line263"></a> *     value.  For elements, this is an offset into the childNodes array.
<a name="line264"></a> */
<a name="line265"></a>goog.dom.AbstractRange.prototype.getFocusOffset = function() {
<a name="line266"></a>  return this.isReversed() ? this.getStartOffset() : this.getEndOffset();
<a name="line267"></a>};
<a name="line268"></a>
<a name="line269"></a>
<a name="line270"></a>/**
<a name="line271"></a> * @return {boolean} Whether the selection is reversed.
<a name="line272"></a> */
<a name="line273"></a>goog.dom.AbstractRange.prototype.isReversed = function() {
<a name="line274"></a>  return false;
<a name="line275"></a>};
<a name="line276"></a>
<a name="line277"></a>
<a name="line278"></a>/**
<a name="line279"></a> * @return {Document} The document this selection is a part of.
<a name="line280"></a> */
<a name="line281"></a>goog.dom.AbstractRange.prototype.getDocument = function() {
<a name="line282"></a>  // Using start node in IE was crashing the browser in some cases so use
<a name="line283"></a>  // getContainer for that browser. It&#39;s also faster for IE, but still slower
<a name="line284"></a>  // than start node for other browsers so we continue to use getStartNode when
<a name="line285"></a>  // it is not problematic. See bug 1687309.
<a name="line286"></a>  return goog.dom.getOwnerDocument(goog.userAgent.IE ?
<a name="line287"></a>      this.getContainer() : this.getStartNode());
<a name="line288"></a>};
<a name="line289"></a>
<a name="line290"></a>
<a name="line291"></a>/**
<a name="line292"></a> * @return {Window} The window this selection is a part of.
<a name="line293"></a> */
<a name="line294"></a>goog.dom.AbstractRange.prototype.getWindow = function() {
<a name="line295"></a>  return goog.dom.getWindow(this.getDocument());
<a name="line296"></a>};
<a name="line297"></a>
<a name="line298"></a>
<a name="line299"></a>/**
<a name="line300"></a> * Tests if this range contains the given range.
<a name="line301"></a> * @param {goog.dom.AbstractRange} range The range to test.
<a name="line302"></a> * @param {boolean=} opt_allowPartial If true, the range can be partially
<a name="line303"></a> *     contained in the selection, otherwise the range must be entirely
<a name="line304"></a> *     contained.
<a name="line305"></a> * @return {boolean} Whether this range contains the given range.
<a name="line306"></a> */
<a name="line307"></a>goog.dom.AbstractRange.prototype.containsRange = goog.abstractMethod;
<a name="line308"></a>
<a name="line309"></a>
<a name="line310"></a>/**
<a name="line311"></a> * Tests if this range contains the given node.
<a name="line312"></a> * @param {Node} node The node to test for.
<a name="line313"></a> * @param {boolean=} opt_allowPartial If not set or false, the node must be
<a name="line314"></a> *     entirely contained in the selection for this function to return true.
<a name="line315"></a> * @return {boolean} Whether this range contains the given node.
<a name="line316"></a> */
<a name="line317"></a>goog.dom.AbstractRange.prototype.containsNode = function(node,
<a name="line318"></a>    opt_allowPartial) {
<a name="line319"></a>  return this.containsRange(goog.dom.Range.createFromNodeContents(node),
<a name="line320"></a>      opt_allowPartial);
<a name="line321"></a>};
<a name="line322"></a>
<a name="line323"></a>
<a name="line324"></a>/**
<a name="line325"></a> * Tests whether this range is valid (i.e. whether its endpoints are still in
<a name="line326"></a> * the document).  A range becomes invalid when, after this object was created,
<a name="line327"></a> * either one or both of its endpoints are removed from the document.  Use of
<a name="line328"></a> * an invalid range can lead to runtime errors, particularly in IE.
<a name="line329"></a> * @return {boolean} Whether the range is valid.
<a name="line330"></a> */
<a name="line331"></a>goog.dom.AbstractRange.prototype.isRangeInDocument = goog.abstractMethod;
<a name="line332"></a>
<a name="line333"></a>
<a name="line334"></a>/**
<a name="line335"></a> * @return {boolean} Whether the range is collapsed.
<a name="line336"></a> */
<a name="line337"></a>goog.dom.AbstractRange.prototype.isCollapsed = goog.abstractMethod;
<a name="line338"></a>
<a name="line339"></a>
<a name="line340"></a>/**
<a name="line341"></a> * @return {string} The text content of the range.
<a name="line342"></a> */
<a name="line343"></a>goog.dom.AbstractRange.prototype.getText = goog.abstractMethod;
<a name="line344"></a>
<a name="line345"></a>
<a name="line346"></a>/**
<a name="line347"></a> * Returns the HTML fragment this range selects.  This is slow on all browsers.
<a name="line348"></a> * The HTML fragment may not be valid HTML, for instance if the user selects
<a name="line349"></a> * from a to b inclusively in the following html:
<a name="line350"></a> *
<a name="line351"></a> * &amp;gt;div&amp;lt;a&amp;gt;/div&amp;lt;b
<a name="line352"></a> *
<a name="line353"></a> * This method will return
<a name="line354"></a> *
<a name="line355"></a> * a&amp;lt;/div&amp;gt;b
<a name="line356"></a> *
<a name="line357"></a> * If you need valid HTML, use {@link #getValidHtml} instead.
<a name="line358"></a> *
<a name="line359"></a> * @return {string} HTML fragment of the range, does not include context
<a name="line360"></a> *     containing elements.
<a name="line361"></a> */
<a name="line362"></a>goog.dom.AbstractRange.prototype.getHtmlFragment = goog.abstractMethod;
<a name="line363"></a>
<a name="line364"></a>
<a name="line365"></a>/**
<a name="line366"></a> * Returns valid HTML for this range.  This is fast on IE, and semi-fast on
<a name="line367"></a> * other browsers.
<a name="line368"></a> * @return {string} Valid HTML of the range, including context containing
<a name="line369"></a> *     elements.
<a name="line370"></a> */
<a name="line371"></a>goog.dom.AbstractRange.prototype.getValidHtml = goog.abstractMethod;
<a name="line372"></a>
<a name="line373"></a>
<a name="line374"></a>/**
<a name="line375"></a> * Returns pastable HTML for this range.  This guarantees that any child items
<a name="line376"></a> * that must have specific ancestors will have them, for instance all TDs will
<a name="line377"></a> * be contained in a TR in a TBODY in a TABLE and all LIs will be contained in
<a name="line378"></a> * a UL or OL as appropriate.  This is semi-fast on all browsers.
<a name="line379"></a> * @return {string} Pastable HTML of the range, including context containing
<a name="line380"></a> *     elements.
<a name="line381"></a> */
<a name="line382"></a>goog.dom.AbstractRange.prototype.getPastableHtml = goog.abstractMethod;
<a name="line383"></a>
<a name="line384"></a>
<a name="line385"></a>/**
<a name="line386"></a> * Returns a RangeIterator over the contents of the range.  Regardless of the
<a name="line387"></a> * direction of the range, the iterator will move in document order.
<a name="line388"></a> * @param {boolean=} opt_keys Unused for this iterator.
<a name="line389"></a> * @return {goog.dom.RangeIterator} An iterator over tags in the range.
<a name="line390"></a> */
<a name="line391"></a>goog.dom.AbstractRange.prototype.__iterator__ = goog.abstractMethod;
<a name="line392"></a>
<a name="line393"></a>
<a name="line394"></a>// RANGE ACTIONS
<a name="line395"></a>
<a name="line396"></a>
<a name="line397"></a>/**
<a name="line398"></a> * Sets this range as the selection in its window.
<a name="line399"></a> */
<a name="line400"></a>goog.dom.AbstractRange.prototype.select = goog.abstractMethod;
<a name="line401"></a>
<a name="line402"></a>
<a name="line403"></a>/**
<a name="line404"></a> * Removes the contents of the range from the document.
<a name="line405"></a> */
<a name="line406"></a>goog.dom.AbstractRange.prototype.removeContents = goog.abstractMethod;
<a name="line407"></a>
<a name="line408"></a>
<a name="line409"></a>/**
<a name="line410"></a> * Inserts a node before (or after) the range.  The range may be disrupted
<a name="line411"></a> * beyond recovery because of the way this splits nodes.
<a name="line412"></a> * @param {Node} node The node to insert.
<a name="line413"></a> * @param {boolean} before True to insert before, false to insert after.
<a name="line414"></a> * @return {Node} The node added to the document.  This may be different
<a name="line415"></a> *     than the node parameter because on IE we have to clone it.
<a name="line416"></a> */
<a name="line417"></a>goog.dom.AbstractRange.prototype.insertNode = goog.abstractMethod;
<a name="line418"></a>
<a name="line419"></a>
<a name="line420"></a>/**
<a name="line421"></a> * Replaces the range contents with (possibly a copy of) the given node.  The
<a name="line422"></a> * range may be disrupted beyond recovery because of the way this splits nodes.
<a name="line423"></a> * @param {Node} node The node to insert.
<a name="line424"></a> * @return {Node} The node added to the document.  This may be different
<a name="line425"></a> *     than the node parameter because on IE we have to clone it.
<a name="line426"></a> */
<a name="line427"></a>goog.dom.AbstractRange.prototype.replaceContentsWithNode = function(node) {
<a name="line428"></a>  if (!this.isCollapsed()) {
<a name="line429"></a>    this.removeContents();
<a name="line430"></a>  }
<a name="line431"></a>
<a name="line432"></a>  return this.insertNode(node, true);
<a name="line433"></a>};
<a name="line434"></a>
<a name="line435"></a>
<a name="line436"></a>/**
<a name="line437"></a> * Surrounds this range with the two given nodes.  The range may be disrupted
<a name="line438"></a> * beyond recovery because of the way this splits nodes.
<a name="line439"></a> * @param {Element} startNode The node to insert at the start.
<a name="line440"></a> * @param {Element} endNode The node to insert at the end.
<a name="line441"></a> */
<a name="line442"></a>goog.dom.AbstractRange.prototype.surroundWithNodes = goog.abstractMethod;
<a name="line443"></a>
<a name="line444"></a>
<a name="line445"></a>// SAVE/RESTORE
<a name="line446"></a>
<a name="line447"></a>
<a name="line448"></a>/**
<a name="line449"></a> * Saves the range so that if the start and end nodes are left alone, it can
<a name="line450"></a> * be restored.
<a name="line451"></a> * @return {goog.dom.SavedRange} A range representation that can be restored
<a name="line452"></a> *     as long as the endpoint nodes of the selection are not modified.
<a name="line453"></a> */
<a name="line454"></a>goog.dom.AbstractRange.prototype.saveUsingDom = goog.abstractMethod;
<a name="line455"></a>
<a name="line456"></a>
<a name="line457"></a>/**
<a name="line458"></a> * Saves the range using HTML carets. As long as the carets remained in the
<a name="line459"></a> * HTML, the range can be restored...even when the HTML is copied across
<a name="line460"></a> * documents.
<a name="line461"></a> * @return {goog.dom.SavedCaretRange?} A range representation that can be
<a name="line462"></a> *     restored as long as carets are not removed. Returns null if carets
<a name="line463"></a> *     could not be created.
<a name="line464"></a> */
<a name="line465"></a>goog.dom.AbstractRange.prototype.saveUsingCarets = function() {
<a name="line466"></a>  return (this.getStartNode() &amp;&amp; this.getEndNode()) ?
<a name="line467"></a>      new goog.dom.SavedCaretRange(this) : null;
<a name="line468"></a>};
<a name="line469"></a>
<a name="line470"></a>
<a name="line471"></a>// RANGE MODIFICATION
<a name="line472"></a>
<a name="line473"></a>
<a name="line474"></a>/**
<a name="line475"></a> * Collapses the range to one of its boundary points.
<a name="line476"></a> * @param {boolean} toAnchor Whether to collapse to the anchor of the range.
<a name="line477"></a> */
<a name="line478"></a>goog.dom.AbstractRange.prototype.collapse = goog.abstractMethod;
<a name="line479"></a>
<a name="line480"></a>// RANGE ITERATION
<a name="line481"></a>
<a name="line482"></a>
<a name="line483"></a>
<a name="line484"></a>/**
<a name="line485"></a> * Subclass of goog.dom.TagIterator that iterates over a DOM range.  It
<a name="line486"></a> * adds functions to determine the portion of each text node that is selected.
<a name="line487"></a> * @param {Node} node The node to start traversal at.  When null, creates an
<a name="line488"></a> *     empty iterator.
<a name="line489"></a> * @param {boolean=} opt_reverse Whether to traverse nodes in reverse.
<a name="line490"></a> * @constructor
<a name="line491"></a> * @extends {goog.dom.TagIterator}
<a name="line492"></a> */
<a name="line493"></a>goog.dom.RangeIterator = function(node, opt_reverse) {
<a name="line494"></a>  goog.dom.TagIterator.call(this, node, opt_reverse, true);
<a name="line495"></a>};
<a name="line496"></a>goog.inherits(goog.dom.RangeIterator, goog.dom.TagIterator);
<a name="line497"></a>
<a name="line498"></a>
<a name="line499"></a>/**
<a name="line500"></a> * @return {number} The offset into the current node, or -1 if the current node
<a name="line501"></a> *     is not a text node.
<a name="line502"></a> */
<a name="line503"></a>goog.dom.RangeIterator.prototype.getStartTextOffset = goog.abstractMethod;
<a name="line504"></a>
<a name="line505"></a>
<a name="line506"></a>/**
<a name="line507"></a> * @return {number} The end offset into the current node, or -1 if the current
<a name="line508"></a> *     node is not a text node.
<a name="line509"></a> */
<a name="line510"></a>goog.dom.RangeIterator.prototype.getEndTextOffset = goog.abstractMethod;
<a name="line511"></a>
<a name="line512"></a>
<a name="line513"></a>/**
<a name="line514"></a> * @return {Node} node The iterator&#39;s start node.
<a name="line515"></a> */
<a name="line516"></a>goog.dom.RangeIterator.prototype.getStartNode = goog.abstractMethod;
<a name="line517"></a>
<a name="line518"></a>
<a name="line519"></a>/**
<a name="line520"></a> * @return {Node} The iterator&#39;s end node.
<a name="line521"></a> */
<a name="line522"></a>goog.dom.RangeIterator.prototype.getEndNode = goog.abstractMethod;
<a name="line523"></a>
<a name="line524"></a>
<a name="line525"></a>/**
<a name="line526"></a> * @return {boolean} Whether a call to next will fail.
<a name="line527"></a> */
<a name="line528"></a>goog.dom.RangeIterator.prototype.isLast = goog.abstractMethod;
</pre>


</body>
</html>
